package com.example.orderflow.controller;

import java.util.List;

import com.example.orderflow.controller.base.ABaseController;
import com.example.orderflow.entity.query.ApprovalProcessQuery;
import com.example.orderflow.entity.po.ApprovalProcess;
import com.example.orderflow.entity.vo.ResponseVO;
import com.example.orderflow.service.ApprovalProcessService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  Controller
 */
@RestController("approvalProcessController")
@RequestMapping("/approvalProcess")
public class ApprovalProcessController extends ABaseController {

	@Resource
	private ApprovalProcessService approvalProcessService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(ApprovalProcessQuery query){
		return getSuccessResponseVO(approvalProcessService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(ApprovalProcess bean) {
		approvalProcessService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<ApprovalProcess> listBean) {
		approvalProcessService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<ApprovalProcess> listBean) {
		approvalProcessService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getApprovalProcessById")
	public ResponseVO getApprovalProcessById(Integer id) {
		return getSuccessResponseVO(approvalProcessService.getApprovalProcessById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateApprovalProcessById")
	public ResponseVO updateApprovalProcessById(ApprovalProcess bean,Integer id) {
		approvalProcessService.updateApprovalProcessById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteApprovalProcessById")
	public ResponseVO deleteApprovalProcessById(Integer id) {
		approvalProcessService.deleteApprovalProcessById(id);
		return getSuccessResponseVO(null);
	}
}